package Runde1;

public class Student {
	
	private final String matrNr;
	private String fName;
	private String lName;
	
	/**
	 * Creates a new student.
	 * 
	 * @param matrNr - matriculation number
	 * @param fName - first name
	 * @param lName - last name
	 * @throws IllegalStudentException - Invalid matrNr or empty fName/lName
	 */
	public Student (String matrNr, String fName, String lName) throws IllegalStudentException{
		if (matrNr.length() != 7) {
			throw new IllegalStudentException("matrNr has a invalid length: " + matrNr + " (" + matrNr.length() + "), should be 7");
		}
		this.matrNr = matrNr;
		
		if (fName.equals("")) {
			throw new IllegalStudentException("fName must not be empty");
		}
		this.fName = fName;
		
		if (lName.equals("")) {
			throw new IllegalStudentException("lName must not be empty");
		}
		this.lName = lName;
	}
	
	/**
	 * @return - returns student's full name
	 */
	public String getName(){
		return fName + " " + lName;
	}
	/**
	 * @return - returns student's matriculation number
	 */
	public String getMatrNr(){
		return matrNr;
	}
}
